package com.firefly.admin.common.handle;

import com.firefly.admin.common.enums.ResultCodeEnum;
import com.firefly.admin.common.utils.ResponseUtil;
import com.firefly.admin.common.vo.Result;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Component
public class RestAuthorizationEntryPointHandler implements AuthenticationEntryPoint {
    @Override
    public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException e) {
        ResponseUtil.returnFail(response, Result.getResult(ResultCodeEnum.UNAUTHORIZED));
    }
}
